<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>模板基本资料</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${global_templets_skin}/systemstyle/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${global_templets_skin}/systemstyle/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">模板基本资料</div>
                <div class="layui-card-body" pad15>
                    <div class="layui-form" lay-filter="">
                        <div class="layui-form-item">
                            <label class="layui-form-label">模板主题</label>
                            <div class="layui-input-inline">
                                <input type="text" name="templateName" value="${tp.templateName!}" lay-verify="required" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">模板名称，可用于用户搜索</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">模块分类</label>
                            <div class="layui-input-inline">
                                <select name="templateType" lay-filter="templateType" lay-verify="required" lay-search="">
                                    <option value="">请选择该模板类型</option>
                                    <#list column as list>
                                    <option value="${list.id}" <#if list.id==tp.templateType> selected = "selected"</#if>>${list.columnName!}</option>
                                    </#list>
                                </select>
                            </div>
                            <div class="layui-form-mid layui-word-aux">模板类别</div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">模板预览</label>
                            <div class="layui-input-inline">
                                <input name="previewUrl" lay-verify="required" id="LAY_avatarSrc" placeholder="图片地址" value="${tp.previewUrl!}" class="layui-input">
                            </div>
                            <div class="layui-input-inline layui-btn-container" style="width: auto;">
                                <button type="button" class="layui-btn layui-btn-primary" id="LAY_avatarUpload">
                                    <i class="layui-icon">&#xe67c;</i>上传图片
                                </button>
                                <button class="layui-btn layui-btn-primary" layadmin-event="avartatPreview">查看图片</button >
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">零售价格</label>
                            <div class="layui-input-inline">
                                <input type="text" name="price" value="${tp.price!}" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">促销折扣</label>
                            <div class="layui-input-inline">
                                <input type="text" name="discount" value="${tp.discount!}" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">支持手机端</label>
                            <div class="layui-input-block">
                                <input type="radio" name="terminalMobile" value="0" title="否"<#if tp.terminalMobile==0> checked="checked"</#if>>
                                <input type="radio" name="terminalMobile" value="1" title="是"<#if tp.terminalMobile==1> checked="checked"</#if>>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">支持PC端</label>
                            <div class="layui-input-block">
                                <input type="radio" name="terminalPc" value="0" title="否"<#if tp.terminalPc==0> checked="checked"</#if>>
                                <input type="radio" name="terminalPc" value="1" title="是"<#if tp.terminalPc==1> checked="checked"</#if>>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">支持PC端</label>
                            <div class="layui-input-block">
                                <input type="radio" name="terminalIpad" value="0" title="否"<#if tp.terminalIpad==0> checked="checked"</#if>>
                                <input type="radio" name="terminalIpad" value="1" title="是"<#if tp.terminalIpad==1> checked="checked"</#if>>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">开发者公司</label>
                            <div class="layui-input-inline">
                                <input type="text" name="companyName" value="${tp.companyName!}" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">开发者主页</label>
                            <div class="layui-input-inline">
                                <input type="text" name="siteUrl" value="${tp.siteUrl!}" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">模板说明</label>
                            <div class="layui-input-block">
                                <textarea name="remark" placeholder="请输入内容" class="layui-textarea">${tp.remark!}</textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <input type="hidden" name="id" id="id" value="${id!}">
                                <button class="layui-btn" lay-submit lay-filter="setTemplate">确认修改</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重新填写</button>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

<script src="${global_templets_skin}/systemstyle/layui/layui.js"></script>
<script>
    layui.config({
        base: '${global_templets_skin}/systemstyle/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'set','form'], function () {
        var form   = layui.form;
        var $      = layui.jquery;
        var layer  = layui.layer;

        form.on('submit(setTemplate)', function(data) {
            $.ajax({
                url:'/admin/template/add.do',
                type:'post',
                dataType: 'json',
                data: data.field,
                success:function(e){
                    if (e.code == "0") {
                        layer.msg('成功');
                        window.location.reload();
                    }else {
                        layer.msg(e.message, {icon: 2});
                    }
                }
            })
            //防止页面跳转
            return false;
        });
    });
</script>
</body>
</html>